<template>
  <div class="app-container">
    <el-form :inline="true" ref="ruleForm" :model="formInline" class="demo-form-inline">
      <el-form-item label="">
        <el-col :span="7">
          <el-form-item prop="dateType">
            <el-select v-model="formInline.dateType" placeholder="请选择时间范围">
              <el-option :label="$t('language.finance.withdrawal.requestTime')" :value="1"></el-option>
              <el-option :label="$t('language.finance.withdrawal.dispenseTime')" :value="4"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="14">
          <el-form-item prop="time">
            <el-date-picker
              v-model="formInline.time"
              type="datetimerange"
              align="right"
              unlink-panels
              :range-separator="$t('language.finance.recharge.to')"
             :start-placeholder="$t('language.finance.recharge.startDate')"
             :end-placeholder="$t('language.finance.recharge.endDate')"
              :default-time="['00:00:00', '23:59:59']"
              value-format="yyyy-MM-dd HH:mm:ss">
            </el-date-picker>
          </el-form-item>
        </el-col>
      </el-form-item>
      <el-form-item class="with-pre-select" prop="keywords">
        <el-input :placeholder="$t('language.finance.publicFilters.keyword')" v-model="formInline.keywords" class="input-with-select" @keyup.enter.native="$emit('on-filter',formInline)">
          <el-select
            v-model="formInline.searchType" slot="prepend" placeholder="查询范围">
            <el-option :label="$t('language.finance.withdrawal.billNo')" :value="1"></el-option>
          </el-select>
        </el-input>
      </el-form-item>
      <el-form-item label="" prop="splitType">
        <el-checkbox-group v-model="formInline.splitType">
          <el-checkbox :label="$t('language.finance.withdrawal.associatedDetachableSingleSearch')" name="splitType"></el-checkbox>
        </el-checkbox-group>
      </el-form-item>
      <el-form-item :label="$t('language.finance.withdrawal.paymentType')" prop="withdrawType">
        <el-select
          v-model="formInline.withdrawType" :placeholder="$t('language.finance.publicFilters.selectPayoutType')">
          <el-option :label="$t('language.finance.publicFilters.all')" :value="-1"></el-option>
         <el-option :label="$t('language.finance.withdrawal.threePartiesPayAutomatically')" :value="1"></el-option>
          <el-option :label="$t('language.finance.withdrawal.threeManualPayment')" :value="2"></el-option>
          <el-option :label="$t('language.finance.withdrawal.artificialoutMoney')" :value="0"></el-option>
        </el-select>
      </el-form-item>
      <!-- <el-form-item label="状态：" prop="status">
        <el-select
          v-model="formInline.status" placeholder="请选择出款类型">
          <el-option :label="'处理中'" :value="11"></el-option>
          <el-option :label="'待出款'" :value="0"></el-option>
          <el-option :label="'自动出款失败'" :value="7"></el-option>
          <el-option :label="'风险待审核'" :value="-3"></el-option>
        </el-select>
      </el-form-item> -->
      <el-form-item :label="$t('language.finance.withdrawal.status')" prop="status">
        <el-select
          :style="{width: '230px'}"
          multiple
          :collapse-tags="true"
          v-model="formInline.status" width="100%"  :placeholder="$t('language.finance.publicFilters.selectStatus')">
          <el-option
            v-for="item in $t('language.finance.consts.WITHDRAW_STATUS_THREE')"
            :label="item.title"
            :key="item.value"
            :value="item.value"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item :label="$t('language.finance.recharge.level')" prop="userLevel">
        <el-select :collapse-tags="true" v-model="formInline.userLevel" multiple :placeholder="formInline.userLevel?'':$t('language.finance.publicFilters.selectLevel')">
          <el-option
            v-for="item in levelList"
            :label="item.name"
            :key="item.levelId"
            :value="item.levelId"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item :label="$t('language.finance.withdrawal.splitState')" prop="splitStatus">
        <el-select v-model="formInline.splitStatus" :placeholder="$t('language.finance.publicFilters.selectSplitStatus')">
          <el-option
            :label="$t('language.finance.publicFilters.all')"
            :key="consts.ALL"
            :value="-1"
          ></el-option>
          <el-option :label="$t('language.finance.withdrawal.splited')" :value="1"></el-option>
          <el-option :label="$t('language.finance.withdrawal.notSplit')" :value="0"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item :label="$t('language.finance.withdrawal.separateStatus')" prop="seperatorStatus">
        <el-select
          v-model="formInline.seperatorStatus" :placeholder="$t('language.finance.publicFilters.selectStatus')">
          <el-option :label="$t('language.finance.publicFilters.all')" :value="-1"></el-option>
          <el-option :label="$t('language.finance.withdrawal.separated')" :value="0"></el-option>
          <el-option :label="$t('language.finance.withdrawal.notSeparate')" :value="1"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item :label="$t('language.finance.withdrawal.dispenseTo')" prop="seperator">
        <el-input v-model="formInline.seperator" :placeholder="$t('language.finance.recharge.inputPrompt')" @keyup.enter.native="$emit('on-filter',formInline)"></el-input>
      </el-form-item>
      <el-form-item :label="$t('language.finance.withdrawal.undispensedType')" prop="seperateReason">
        <el-select
          v-model="formInline.seperateReason" :placeholder="$t('language.finance.publicFilters.selectType')">
          <el-option :label="$t('language.finance.publicFilters.all')" :value="-1"></el-option>
          <el-option :label="$t('language.finance.withdrawal.automaticallyPayout')" :value="0"></el-option>
          <el-option :label="$t('language.finance.withdrawal.beRecycled')" :value="1"></el-option>
          <el-option :label="$t('language.finance.withdrawal.noMatchingCondition')" :value="2"></el-option>
          <el-option :label="$t('language.finance.withdrawal.noOperatorIsConfiguredForMatchingConditions')" :value="3"></el-option>
          <el-option :label="$t('language.finance.withdrawal.nonpureChineseName')" :value="4"></el-option>
        </el-select>
      </el-form-item>
      <el-button class="filter-item" type="primary" icon="el-icon-search" @click="$emit('on-filter',formInline)">{{ $t('language.table.search') }}
      <!-- <el-button class="filter-item" type="primary" icon="el-icon-search" @click="con(formInline.time[0])">搜索 -->
      </el-button>
      <el-button @click="selfResetForm('ruleForm')">{{$t('language.table.reset') }}</el-button>
    </el-form>
  </div>

</template>

<script>
import { getUserLevelList } from '@/services/api/userLevel';
import { getUserGroupList } from '@/services/api/userGroup';
import { form, pickerOption } from '@/build';

export default {
  name: 'seperate-filter',
  props: {
    type: {
      type: String,
      default: 'auto', // 分自动和人工
    },
    tag: {
      type: Number,
      default: 1,
    },
  },
  mixins: [form, pickerOption],
  data() {
    return {
      levelList: [],
      formInline: {
        dateType: 1,
        keywords: undefined,
        searchType: 1,
        splitType: undefined,
        withdrawType: undefined,
        status: [7,0,11],
        userLevel: [],
        splitStatus: undefined,
        seperator: undefined,
        seperateReason: undefined,
        seperatorStatus: undefined,
        time: [moment().format('YYYY-MM-DD 00:00:00'), moment().format('YYYY-MM-DD 23:59:59')],
      },

    };
  },
  methods: {
    selfResetForm(formName) {
      this.resetForm(formName);
      // this.$parent.getAll()
      this.$emit('on-filter', this.formInline);
    },
  },
  mounted() {
    this.bindGet(getUserLevelList, 'levelList', { });
    this.getAll();
  },
};
</script>

<style lang="scss" scoped>
  .with-pre-select {
    .el-input-group__prepend {
      .el-select {
        width: 120px;
      }
    }
  }

  .money-range {
    .el-input {
      width: 100px;
    }
  }

</style>
